package mviewer.types;

import java.util.Collection;
import java.util.LinkedList;

public class Vertex extends VectorData implements IVertex, IWritableVector {

	private IVector normal;
	private Collection<Polygon3d> polygons = new LinkedList<Polygon3d>();

	public Vertex(float x, float y, float z, IVector normal) {
		super(x, y, z);
		this.normal = normal;

		if (normal == null)
			throw new IllegalArgumentException("normal cannot be null");
	}

	public Vertex(IVertex vertex) {
		this(vertex.getX(), vertex.getY(), vertex.getZ(), vertex.getNormal());
	}

	@Override
	public IVector getNormal() {
		return normal;
	}

	public Collection<Polygon3d> getPolygons() {
		return polygons;
	}

	@Override
	public String toString() {
		return String.format("%s{Position : %s, Normal : %s}",
				getClass().getSimpleName(), super.toString(), normal);
	}
}